//
//  WBPublishViewController.swift
//  WeiBo
//
//  Created by chenguanglei on 16/12/4.
//  Copyright © 2016年 itheima. All rights reserved.
//

import UIKit

class WBPublishViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        view.backgroundColor = UIColor.white
        
        setupNav()
    }

    
    private func setupNav(){
    
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "返回", style: UIBarButtonItemStyle.plain, target: self, action: #selector(dismissVC))
    
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "发布", style: UIBarButtonItemStyle.plain, target: self, action: #selector(publish))
        
        let titleView: UILabel = UILabel.init(frame: CGRect.init(x: 0, y: 0, width: 200, height: 44))
        
        titleView.numberOfLines = 0
        
        titleView.textAlignment = .center
        
        let text = "发微博\n广州黑马13期"
        
        let attributeM = NSMutableAttributedString(string: text)
        
        attributeM.addAttributes([NSFontAttributeName: UIFont.systemFont(ofSize: 14), NSForegroundColorAttributeName: UIColor.red], range: NSMakeRange(0, 3))
        
        titleView.attributedText = attributeM
        
        navigationItem.titleView = titleView
        
        
    }
    
    @objc private func dismissVC(){
        
        navigationController?.dismiss(animated: true, completion: nil)
        
    }
    
    @objc private func publish(){
        
        navigationController?.dismiss(animated: false, completion: nil)
        
    }
    
}
